home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / c / strcpy < prev    next >
Text File  |  1996-11-09  |  845b  |  46 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/c/RCS/strcpy,v $
  4.  * $Date: 1996/04/19 21:26:42 $
  5.  * $Revision: 1.1 $
  6.  * $State: Rel $
  7.  * $Author: simon $
  8.  *
  9.  * $Log: strcpy,v $
  10.  * Revision 1.1  1996/04/19 21:26:42  simon
  11.  * Initial revision
  12.  *
  13.  ***************************************************************************/
  14.  
  15. static const char rcs_id[] = "$Id: strcpy,v 1.1 1996/04/19 21:26:42 simon Rel $";
  16.  
  17. #include <string.h>
  18.  
  19. char *
  20. strcpy (char *s, register const char *s2)
  21.  
  22. {
  23.   register char *s1 = s;
  24.  
  25.   while (*s1++ = *s2++);
  26.  
  27.   return (s);
  28. }
  29.  
  30. char *
  31. strncpy (char *s, register const char *s2, register size_t n)
  32.  
  33. {
  34.   register char *s1 = s;
  35.  
  36.   while (n--)
  37.     if (!(*s1++ = *s2++))
  38.       {
  39.     while (n--)
  40.       *s1++ = 0;
  41.     return (s);
  42.       }
  43.  
  44.   return (s);
  45. }
  46.